home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************/
- /* Application Skeleton #2
-
- This program began as an experiment with GEM programming. Starting
- with the "APSKEL.C" supplied with the developers kit, I reorganized
- code for readability, fixed bugs, added new featues and learned
- about some GEM idiosyncrasys. The resulted is a collection of functions
- that should prove useful to beginning GEM programmers. I know
- these examples would have save me a lot of time. Keep in mind that
- GEM programming is not simple - it requires a lot of perseverance.
- Note, the window color feature is not completed.
-
- */
- /*********************************************************************/
- /* INCLUDE FILES */
- /*********************************************************************/
-
- #include <obdefs.h>
- #include <define.h>
- #include <gemdefs.h>
- #include <osbind.h>
- #include <string.h>
-
- /*********************************************************************/
- /* DEFINES */
- /*********************************************************************/
- /* Header file created by the resource construction program
-
- Naming Conventions: _T = object tree
- _O = object
- _M = menu point
- _E = menu entry
- _B = button
- */
- #define MENU_T 0
- #define DESK_M 3
- #define FILE_M 4
- #define SHOW_M 5
- #define HELP_M 7
- #define OPTION_M 6
- #define ABOUT_E 10
- #define ABOUT_T 1
- #define OPEN_E 19
- #define CLOSE_E 20
- #define ABOUT_B 9
- #define QUIT_E 22
- #define WINFO_E 24
- #define SOLFIL_E 27
- #define DOTFIL_E 26
- #define CRSFIL_E 28
- #define TRACE_E 30
- #define HWIND_E 32
- #define HARSLD_E 33
- #define HTRACE_E 34
- #define TRACE_T 5
- #define WINDOW_T 3
- #define WINDOW_B 7
- #define WINFO_T 4
- #define X_O 6
- #define WIDTH_O 9
- #define Y_O 11
- #define ARSLID_T 2
- #define STYLE_O 13
- #define INTER_O 17
- #define COLOR_O 16
- #define HEIGTH_O 18
- #define WINFO_B 19
- #define WINDNB_O 14
- #define ARSLID_B 11
-
- #define WI_KIND (SIZER|MOVER|FULLER|CLOSER|NAME|UPARROW|DNARROW|VSLIDE|LFARROW|RTARROW|HSLIDE)
- #define NO_WINDOW (-1)
- #define MIN_WIDTH (2*gl_wbox)
- #define MIN_HEIGHT (3*gl_hbox)
-
- /* Resource File Info */
- #define RSCF_NAME "APSKEL2.RSC"
- #define RSCNOTFND "[3][ Resource File | 'APSKEL2.RSC' | Not Found ][ EXIT ]"
- #define RSCBAD "[3][ Resource File | 'APSKEL2.RSC' | Is Corrupted ][ EXIT ]"
- #define TOMANY_WI "[3][ Too Many Windows Open ][ OK ]"
-
- #define WI_MAX 8 /* maximum number of windows */
- /*********************************************************************/
- /* EXTERNALS */
- /*********************************************************************/
-
- extern int gl_apid;
-
- /*********************************************************************/
- /* GLOBAL VARIABLES */
- /*********************************************************************/
- int contrl[12]; /* GEM control arrays */
- int intin[128];
- int ptsin[128];
- int intout[128];
- int ptsout[128];
-
- int gl_hchar;
- int gl_wchar;
- int gl_wbox;
- int gl_hbox; /* system sizes */
-
- int ap_id; /* application ID */
- int phys_handle; /* physical workstation handle */
- int v_handle; /* virtual workstation handle */
-
- OBJECT *menutree; /* menu tree address */
-
- struct wi_control { /* WINDOW CONTROL STRUCTURE */
- int handle; /* window handle */
- int style; /* style index */
- int color; /* color index */
- int inter; /* interior index */
- int x; /* initial x coordinate */
- int y; /* initial y coordinate */
- int w; /* initial width */
- int h; /* initial height */
- char name[30]; /* window name */
- } wi_c[WI_MAX];
-
- int wi_nbr=0; /* number of windows open */
- int xdesk,ydesk,hdesk,wdesk; /* desktop coordinates */
-
- int terminat=FALSE; /* terminat flag */
- int dtrace=FALSE; /* debug trace flag */
- int msgbuff[8]; /* event message buffer */
- int fulled; /* current state of window */
- int re_draw; /* redraw top window flag*/
- int hidden; /* current state of cursor */
- int keycode; /* keycode ret. by event-keyboard */
- int butdown; /* button state tested for, UP/DOWN */
- int mx, my; /* mouse x and y pos. */
-
- int work_in[11]; /* Input to GSX parameter array */
- int work_out[57]; /* Output from GSX parameter array */
- int pxyarray[10]; /* input point array */
-
- /****************************************************************/
- /* */
- /* M A I N */
- /* */
- /****************************************************************/
- main()
- {
- start_applic(); /* start application */
- init_wctl(); /* initialize window ctl array */
- get_rscfile(); /* get resource file */
- show_menubar(); /* show menu bar */
- proc_events(); /* process GEM events */
- end_applic(); /* Wrap-up GEM */
- exit(0); /* return (no error) */
- }
- /* */
- /****************************************************************/
- /* start application */
- /****************************************************************/
- start_applic()
- {
- int i;
- ap_id=appl_init();
- phys_handle=graf_handle(&gl_wchar,&gl_hchar,&gl_wbox,&gl_hbox);
- wind_get(0, WF_WORKXYWH, &xdesk, &ydesk, &wdesk, &hdesk);
- /* Open Virtual Workstation */
- for(i=0;i<10;work_in[i++]=1);
- work_in[10]=2;
- v_handle=phys_handle;
- v_opnvwk(work_in,&v_handle,work_out);
- }
- /****************************************************************/
- /* end application */
- /****************************************************************/
- end_applic()
- {
- int i, wh;
- debug_alert("gem_wrap", "CLOSE OPEN WIND/REMOV MENU", 0);
- for(i=0; i<WI_MAX; i++) { /* close any open windows */
- wh=wi_c[i].handle;
- if(wh) {
- wind_close(wh);
- wind_delete(wh);
- }
- }
- menu_bar(menutree, FALSE); /* remove menu bar */
- v_clsvwk(v_handle); /* close virtual work station */
- appl_exit(); /* tell GEM we are done */
- }
- /****************************************************************/
- /* Initialize Window Control Array */
- /****************************************************************/
- init_wctl()
- { /* set default values for windows */
- int i;
- for(i=0; i<WI_MAX; i++) {
- wi_c[i].handle=0; /* clear handle */
- wi_c[i].style=1+(2*i); /* pattern */
- wi_c[i].color=1; /* color */
- wi_c[i].inter=2; /* interior */
- wi_c[i].x=xdesk+(20*i+1); /* location */
- wi_c[i].y=ydesk+(16*i+1);
- wi_c[i].w=wdesk-130; /* size */
- wi_c[i].h=hdesk-110;
- }
- }
- /****************************************************************/
- /* get the resource file */
- /****************************************************************/
- get_rscfile()
- {
- if(!rsrc_load(RSCF_NAME)) { /* load resource file */
- form_alert(1, RSCNOTFND); /* error - file not found, use ALERT */
- end_applic(); /* end application & exit */
- exit(1);
- }
- }
- /***************************************************************/
- /* show menu bar */
- /***************************************************************/
- show_menubar()
- { /* get address of menu tree */
- if(!rsrc_gaddr(R_TREE, MENU_T, &menutree)) {
- form_alert(1, RSCBAD); /* bad rsc file */
- end_applic();
- exit(1);
- }
- menu_bar(menutree, TRUE); /* display menu bar */
- }
- /****************************************************************/
- /* open window */
- /****************************************************************/
- open_window()
- {
- int wh, i, x, y, w, h;
- char s[25];
- wh=wind_create(WI_KIND, xdesk, ydesk, wdesk, hdesk);
- if(wh < 0) return(wh); /* too many windows open */
- i=wi_geti(0);
- debug_alert("open_window", "OPEN A WINDOW", i+1);
- wi_c[i].handle=wh; /* save handle */
- x=wi_c[i].x; /* get initial window size */
- y=wi_c[i].y;
- w=wi_c[i].w;
- h=wi_c[i].h;
- strcpy(s, " Window #"); /* create window name */
- itoa(i+1, s+9, 1);
- strcat(s, " ");
- strcpy(wi_c[i].name, s);
- disp_loc(wh, x, y);
- /* set name & display window */
- wind_set(wh, WF_NAME, wi_c[i].name, 0, 0);
- graf_growbox(x+w/2, y+h/2, gl_wbox, gl_hbox, x, y, w, h);
- wind_open(wh, x, y, w, h);
- wi_nbr++;
- return(wh); /* return handle */
- }
- /****************************************************************/
- /* display window location */
- /****************************************************************/
- disp_loc(wh, x, y)
- int wh, x, y;
- {
- int i;
- char s[25];
- i=wi_geti(wh);
- itoa(x, s, 3); /* make x & y string */
- itoa(y, s+4, 3);
- s[3]=' ';
- strcpy(&wi_c[i].name[12], s); /* and move to control array */
- }
- /****************************************************************/
- /* close window */
- /***************************************************************/
- close_window(wh)
- int wh;
- {
- int i, x, y, w, h;
- wind_get(wh, WF_CURRXYWH, &x, &y, &w, &h);
- i=wi_geti(wh);
- debug_alert("close_window", "CLOSE A WINDOW", i+1);
- wind_close(wh);
- graf_shrinkbox(x+w/2, y+h/2, gl_wbox, gl_hbox, x, y, w, h);
- wind_delete(wh);
- wi_c[wi_geti(wh)].handle=0;
- wi_nbr--;
- }
- /****************************************************************/
- /* Get Window Control Index */
- /****************************************************************/
- wi_geti(wh)
- int wh;
- { /* find the control index that matches the window handle */
- int i;
- for(i=0; i<WI_MAX && wi_c[i].handle!=wh; i++);
- return(i);
- }
- /**************************************************************/
- /* Debug Display */
- /**************************************************************/
- debug_alert(s1, s2, n)
- int n; /* create debug alert box from two strings s1 and s2 , */
- char *s1, *s2; /* and the integer n */
- {
- char s3[110];
- if(dtrace == FALSE) return;
- strcpy(s3, "[3][ ");
- strcat(s3, s1);
- strcat(s3, " | | ");
- strcat(s3, s2);
- strcat(s3, " | ");
- itoa(n, s3+strlen(s3)-1, 6);
- strcat(s3, " | ][ GO ]");
- form_alert(1, s3);
- }
- /**************************************************************/
- /* Integer to Ascii */
- /**************************************************************/
- itoa(n1, s, n2) /* convert n1 to characters in s with minimum */
- int n1, n2; /* length n2 */
- char s[];
- {
- int i, sign;
- if((sign=n1) < 0) /* record sign */
- n1 = -n1; /* make n positive */
- i = 0;
- do { /* generate digits in reverse order */
- s[i++]=n1 % 10 + '0'; /* get next digit */
- }
- while((n1 /= 10) > 0); /* delete it */
- while(i < n2) s[i++] = '0';
- if(sign < 0) s[i++] = '-';
- s[i] = '\0';
- reverse(s);
- }
- reverse(s) /* reverse string s in place */
- char s[];
- {
- int c, i, j;
- for(i=0, j=strlen(s)-1; i< j; i++, j--) {
- c=s[i];
- s[i]=s[j];
- s[j]=c;
- }
- }
- /****************************************************************/
- /* GSX UTILITY ROUTINES. */
- /****************************************************************/
- hide_mouse()
- {
- if(! hidden){
- graf_mouse(M_OFF,0x0L);
- hidden=TRUE;
- }
- }
- show_mouse()
- {
- if(hidden){
- graf_mouse(M_ON,0x0L);
- hidden=FALSE;
- }
- }
- /****************************************************************/
- /* Check if Window is Smaller */
- /****************************************************************/
- wind_smaller(wh)
- int wh;
- { /* is resized window smaller than its previous size ?*/
- /* this check is necessary because GEM does not send */
- /* redraw event message in this case */
- int px, py, pw, ph, x, y, w, h;
- wind_get(wh, WF_CURRXYWH, &x, &y, &w, &h);
- wind_get(wh, WF_PREVXYWH, &px, &py, &pw, &ph);
- if(w < pw && h < ph) return(1);
- return(0);
- }
- /****************************************************************/
- /* Draw Dialog Box
- /****************************************************************/
- draw_dbox(ti, ta)
- int ti; /* tree index */
- long int *ta; /* tree address */
- {
- int x, y, w, h;
- debug_alert("draw_dbox", "DRAW DIALOG BOX", 0);
- rsrc_gaddr(R_TREE, ti, ta); /* get address of tree */
- form_center(*ta, &x, &y, &w, &h); /* get loc of centered tree */
- /* reserve memory for dialog box */
- form_dial(FMD_START, x, y, w, h, 0,0,0,0); /* you need those zeros */
- /* draw growing box */
- form_dial(FMD_GROW, x+w/2, y+h/2, gl_wbox, gl_hbox, x, y, w, h);
- /* draw object tree */
- objc_draw(*ta, ROOT, MAX_DEPTH, x, y, w, h);
- }
- /****************************************************************/
- /* Erase Dialog Box */
- /****************************************************************/
- erase_dbox(ti)
- int ti; /* tree index */
- {
- int x, y, w, h;
- OBJECT *ta;
- debug_alert("erase_dbox", "ERASE DIALOG BOX", 0);
- rsrc_gaddr(R_TREE, ti, &ta); /* get address of tree */
- form_center(ta, &x, &y, &w, &h); /* get loc of centered tree */
- /* release memory used by dialog box */
- form_dial(FMD_FINISH, 0, 0, 0, 0, x, y, w, h);
- /* draw shrinking box */
- form_dial(FMD_SHRINK, x+w/2, y+h/2, gl_wbox, gl_hbox, x, y, w, h);
- }
- /****************************************************************/
- /* Simple Dialog */
- /****************************************************************/
- simple_dialog(ti)
- int ti; /* draw dialog box, wait for user to exit, */
- { /* then erase dialog box */
- OBJECT *ta;
- debug_alert("simple_dialog", "DRAW BOX/WAIT FOR EXIT/ERASE", 0);
- draw_dbox(ti, &ta);
- form_do(ta, 0); /* dialog boxes were created with touch exit buttons */
- erase_dbox(ti);
- }
- /****************************************************************/
- /* Set Clipping Rectangle */
- /****************************************************************/
- set_clip(x, y, w, h)
- int x, y, w, h;
- {
- int clip[4];
- clip[0]=x;
- clip[1]=y;
- clip[2]=x+w-1; /* the -1 was not in the ATARI example */
- clip[3]=y+h-1;
- vs_clip(v_handle, 1, clip);
- }
- /****************************************************************/
- /* Find and Redraw All Clipping Rectangles */
- /****************************************************************/
- do_redraw(wh, xc, yc, wc, hc)
- int wh, xc, yc, wc, hc;
- {
- GRECT t1, t2;
- int i, x, y, w, h;
- i=wi_geti(wh);
- if(wh == 0) return; /* no windows open */
- debug_alert("do_redraw", "FIND/REDRAW CLIPPING RECTANGLES", i+1);
- hide_mouse();
- wind_update(TRUE);
- t2.g_x=xc;
- t2.g_y=yc;
- t2.g_w=wc;
- t2.g_h=hc;
- wind_get(wh, WF_WORKXYWH, &x, &y, &w, &h);
- wind_get(wh, WF_FIRSTXYWH, &t1.g_x, &t1.g_y, &t1.g_w, &t1.g_h);
- while (t1.g_w && t1.g_h) {
- if (rc_intersect(&t2, &t1)) {
- set_clip(t1.g_x, t1.g_y, t1.g_w, t1.g_h);
- draw_ellipse(wi_c[i].inter, wi_c[i].style,
- i+1, x, y, w, h);
- }
- wind_get(wh, WF_NEXTXYWH, &t1.g_x, &t1.g_y, &t1.g_w, &t1.g_h);
- }
- wind_update(FALSE);
- show_mouse();
- }
- /****************************************************************/
- /* Draw Filled Ellipse. */
- /****************************************************************/
- draw_ellipse(in, sty, col, x, y, w, h)
- int in, sty, col, x, y, w, h;
- {
- int temp[4];
- debug_alert("draw_ellipse", "DRAW ELLIPSE IN LOC SPECIFIED", 0);
- vsf_interior(v_handle, 1);
- vsf_color(v_handle, 0);
- temp[0]=x;
- temp[1]=y;
- temp[2]=x+w-1;
- temp[3]=y+h-1;
- v_bar(v_handle, temp); /* blank the interior */
- vsf_interior(v_handle, in);
- vsf_style(v_handle, sty);
- vsf_color(v_handle, col);
- v_ellipse(v_handle, x+w/2, y+h/2, w/2, h/2);
- }
- /****************************************************************/
- /* user closed a window */
- /***************************************************************/
- user_close()
- {
- int i, x, y, w, h, wh;
- wind_get(i, WF_TOP, &wh, &y, &w, &h);
- i=wi_geti(wh);
- debug_alert("user_close", "CLOSE WINDOW/UPDATE MENU", i+1);
- if(wi_nbr)
- close_window(wh);
- if(wi_nbr < WI_MAX)
- menu_ienable(menutree, OPEN_E, TRUE);
- if(!wi_nbr)
- menu_ienable(menutree, CLOSE_E, FALSE);
- }
- /****************************************************************/
- /* Set Window Interior Style */
- /****************************************************************/
- set_inter(st)
- int st;
- {
- int i, j, x, y, w, h, wh;
- wind_get(i, WF_TOP, &wh, &y, &w, &h);
- i=wi_geti(wh);
- if(wh == 0) return; /* no windows open */
- debug_alert("set_inter", "SET INTERIOR STYLE/OPTION MENU", i+1);
- wi_c[i].inter=st;
- menutree[DOTFIL_E].ob_state &= ~CHECKED; /* remove checks from */
- menutree[SOLFIL_E].ob_state &= ~CHECKED; /* interior option menu */
- menutree[CRSFIL_E].ob_state &= ~CHECKED;
- switch(st) { /* now check interior */
- case 1: /* passed as a argument */
- menutree[SOLFIL_E].ob_state |= CHECKED;
- break;
- case 2:
- menutree[DOTFIL_E].ob_state |= CHECKED;
- break;
- case 3:
- menutree[CRSFIL_E].ob_state |= CHECKED;
- break;
- }
- j=1000/style_max(i); /* calc size of slider */
- wind_set(wh, 16, j, y, w, h); /* set size of slider */
- j=1000*(wi_c[i].style-1)/(style_max(i)-1); /* calc pos. of slider */
- wind_set(wh, WF_VSLIDE, j, y, w, h); /* set pos. of slider */
- }
- /****************************************************************/
- /* Get Maximum Style Index Value for Top Window */
- /****************************************************************/
- style_max(i)
- int i;
- {
- switch(wi_c[i].inter) {
- case 1: return(1);
- case 2: return(24);
- case 3: return(12);
- }
- return(0);
- }
- /****************************************************************/
- /* Update Window Information in the Dialog Box */
- /****************************************************************/
- up_winfo()
- { /* an example of modifying text objects */
- int x, y, w, h, i, wh;
- OBJECT *ta;
- wind_get(i, WF_TOP, &wh, &y, &w, &h);
- i=wi_geti(wh);
- debug_alert("up_winfo", "UPDATE WIND INFO IN DIALOG BOX", i+1);
- wind_get(wh, WF_CURRXYWH, &x, &y, &w, &h);
- if(!rsrc_gaddr(R_TREE, WINFO_T, &ta)) return;
- itoa(i+1, ((TEDINFO *)ta[WINDNB_O].ob_spec)->te_ptext, 1);
- itoa(x, ((TEDINFO *)ta[X_O].ob_spec)->te_ptext, 3);
- itoa(y, ((TEDINFO *)ta[Y_O].ob_spec)->te_ptext, 3);
- itoa(w, ((TEDINFO *)ta[WIDTH_O].ob_spec)->te_ptext, 3);
- itoa(h, ((TEDINFO *)ta[HEIGTH_O].ob_spec)->te_ptext, 3);
- itoa(wi_c[i].color, ((TEDINFO *)ta[COLOR_O].ob_spec)->te_ptext, 3);
- itoa(wi_c[i].style, ((TEDINFO *)ta[STYLE_O].ob_spec)->te_ptext, 2);
- itoa(wi_c[i].inter, ((TEDINFO *)ta[INTER_O].ob_spec)->te_ptext, 1);
- }
- /****************************************************************/
- /* Process MENU selection */
- /****************************************************************/
- proc_menu()
- {
- int i, j, x, y ,w, h, wh;
- debug_alert("proc_menu", "PROCESS MENU BAR SELECTION", 0);
- switch(msgbuff[4]) {
- case OPEN_E:
- if(wi_nbr < WI_MAX) {
- wh=open_window();
- if(wh < 0)
- form_alert(1, TOMANY_WI);
- else {
- i=wi_geti(wh);
- set_inter(wi_c[i].inter);
- j=1000/512; /* calc size of slider */
- wind_set(msgbuff[3], 15, j, y, w, h);/* set size of slider */
- menu_ienable(menutree, CLOSE_E, TRUE);
- }
- }
- if(wi_nbr > WI_MAX-1)
- menu_ienable(menutree, OPEN_E, FALSE);
- break;
- case CLOSE_E:
- user_close();
- break;
- case ABOUT_E:
- simple_dialog(ABOUT_T);
- break;
- case HWIND_E:
- simple_dialog(WINDOW_T);
- break;
- case HARSLD_E:
- simple_dialog(ARSLID_T);
- break;
- case HTRACE_E:
- simple_dialog(TRACE_T);
- break;
- case TRACE_E:
- menutree[TRACE_E].ob_state ^= CHECKED;
- dtrace^=TRUE;
- break;
- case DOTFIL_E:
- set_inter(2);
- re_draw=TRUE;
- break;
- case SOLFIL_E:
- set_inter(1);
- re_draw=TRUE;
- break;
- case CRSFIL_E:
- set_inter(3);
- re_draw=TRUE;
- break;
- case WINFO_E:
- up_winfo();
- simple_dialog(WINFO_T);
- break;
- case QUIT_E:
- terminat=TRUE;
- }
- menu_tnormal(menutree, msgbuff[3]); /* reset menu title */
- }
- /****************************************************************/
- /* Process GEM Events */
- /***************************************************************/
- proc_events()
- {
- int event, init_info, x, y, w, h, i, j, k, wh;
- debug_alert("proc_events", "PROCESS GEM EVENT MESSAGES ", 0);
- fulled=init_info=FALSE;
- graf_mouse(ARROW,0x0L); /* set mouse shape */
- while(terminat == FALSE) {
- event = evnt_multi(MU_MESAG | MU_BUTTON | MU_KEYBD,
- 1,1,butdown,
- 0,0,0,0,0,
- 0,0,0,0,0,
- msgbuff,0,0,&mx,&my,&j,&j,&keycode,&j);
-
- re_draw=FALSE;
- wind_update(TRUE);
- if (event & MU_MESAG) {
- i=wi_geti(msgbuff[3]); /* get window control index */
- switch (msgbuff[0]) {
- case MN_SELECTED:
- proc_menu();
- break;
- case WM_REDRAW:
- debug_alert("proc_events", "REDRAW EVENT", i+1);
- do_redraw(msgbuff[3],msgbuff[4],msgbuff[5],msgbuff[6],
- msgbuff[7]);
- break;
- case WM_NEWTOP:
- case WM_TOPPED:
- debug_alert("proc_events", "NEW/TOPPED EVENT", i+1);
- wind_set(msgbuff[3],WF_TOP,0,0,0,0);
- set_inter(wi_c[i].inter);
- break;
- case WM_SIZED:
- case WM_MOVED:
- debug_alert("proc_events", "MOVED/SIZED EVENT", i+1);
- fulled = FALSE;
- if(msgbuff[6]<MIN_WIDTH)msgbuff[6]=MIN_WIDTH;
- if(msgbuff[7]<MIN_HEIGHT)msgbuff[7]=MIN_HEIGHT;
- wind_set(msgbuff[3],WF_CURRXYWH,msgbuff[4],msgbuff[5],
- msgbuff[6],msgbuff[7]);
- disp_loc(msgbuff[3], msgbuff[4], msgbuff[5]);
- wind_set(msgbuff[3], WF_NAME, wi_c[i].name, 0, 0);
- if(wind_smaller(msgbuff[3])) {
- re_draw=TRUE;
- }
- break;
- case WM_FULLED:
- debug_alert("proc_events", "FULLED EVENT", i+1);
- if(fulled) { /* the window is fulled, revert to */
- /* previous size */
- wind_get(msgbuff[3], WF_PREVXYWH, &x, &y, &w, &h);
- wind_set(msgbuff[3],WF_CURRXYWH, x, y, w, h);
- disp_loc(msgbuff[3], x, y);
- /* this check is necessary because GEM */
- /* doesn't send a redraw event when the */
- /* previous X & Y is the upper left corner */
- /* of the screen */
- if(wind_smaller(msgbuff[3]))
- if(x == 0 && y < 20)
- re_draw=TRUE;
- }
- else { /* the window is not fulled, make */
- /* full size of desktop */
- wind_set(msgbuff[3],WF_CURRXYWH, xdesk, ydesk,
- wdesk, hdesk);
- disp_loc(msgbuff[3], xdesk, ydesk);
- }
- wind_set(msgbuff[3], WF_NAME, wi_c[i].name, 0, 0);
- fulled ^= TRUE;
- break;
- case WM_ARROWED:
- if(msgbuff[4] > 3) { /* horizontal arrows */
- debug_alert("proc_events", "HORIZ. ARROW EVENT", i+1);
- if(msgbuff[4] == 4 || msgbuff[4] == 6)
- wi_c[i].color--;
- if(msgbuff[4] == 5 || msgbuff[4] == 7)
- wi_c[i].color++;
- Setcolor(i+1, wi_c[i].color);
- j=1000l*wi_c[i].color/512l;
- wind_set(msgbuff[3], WF_HSLIDE, j, y, w, h);
- }
- else { /* vertical arrows */
- debug_alert("proc_events", "VERT. ARROW EVENT", i+1);
- if(msgbuff[4] == 3 || msgbuff[4] == 1)
- wi_c[i].style++;
- if(msgbuff[4] == 2 || msgbuff[4] == 0)
- wi_c[i].style--;
- j=wi_c[i].style;
- if(j < 1)
- wi_c[i].style=1;
- if(j > style_max(i))
- wi_c[i].style=style_max(i);
- /* calc pos. of slider */
- j=1000*(wi_c[i].style-1)/(style_max(i)-1);
- /* set pos. of slider */
- wind_set(msgbuff[3], WF_VSLIDE, j, y, w, h);
- re_draw=TRUE;
- }
- break;
- case WM_VSLID:
- debug_alert("proc_events", "VERT. SLIDER EVENT", i+1);
- /* calc style value from slider pos */
- wi_c[i].style=(msgbuff[4]*style_max(i))/1000;
- /* set slider to new pos */
- wind_set(msgbuff[3], WF_VSLIDE, msgbuff[4], y, w, h);
- re_draw=TRUE;
- break;
- case WM_HSLID:
- debug_alert("proc_events", "HORIZ. SLIDER EVENT", i+1);
- j=(msgbuff[4]*512l)/1000l;
- Setcolor(i+1, j);
- wi_c[i].color=j;
- wind_set(msgbuff[3], WF_HSLIDE, msgbuff[4], y, w, h);
- break;
- case WM_CLOSED:
- debug_alert("proc_events", "WINDOW CLOSE EVENT", i+1);
- user_close();
- break;
- }
- }
- if(re_draw == TRUE) {
- wind_get(i, WF_TOP, &wh, &y, &w, &h);
- wind_get(wh, WF_CURRXYWH, &x, &y, &w, &h);
- do_redraw(wh, x, y, w, h);
- }
- wind_update(FALSE);
-
- /* This could not be done in MAIN because the mouse pointer */
- /* stayed busy until after the dialog box was clicked */
- /* I believe this is caused by the initial redraw event that */
- /* GEM sends for a non-existent window */
- if(init_info == FALSE) {
- simple_dialog(ABOUT_T); /* show openning dialog box */
- init_info=TRUE;
- }
- }
- }
-